import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { ObjCreate } from "../common/ObjCreate";
import { TilePanel } from "../equipment/TilePanel";
import { PrizeFallRender } from "./PrizeFallRender";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { Language } from "../../../../extend/language/Language";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { TaskTargetInfo } from "../../model/TaskTargetInfo";
import { EntityType } from "../../rules/EntityType";
import { AIManager } from "../../scene/ai/AIManager";
import { AIType } from "../../scene/ai/AIType";
import { Cache } from "../../cache/Cache";
import { MsgManager } from "../../manager/MsgManager";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { GButton } from "../../../../com/mui/controls/GButton";
//class PrizeFallCrossWindow
    
    export  class PrizeFallCrossWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            this._randomArr = [{"x": 10, "y": 226}, {"x": 14, "y": 229}];
            super(arg1);
            setSize(428, 335);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._bg = ObjCreate.createBitmap("", 14, 38, this);
            this._desTx = ObjCreate.createTextField("", 28, 45, 357, 135, this);
            var loc2;
            this._desTx.multiline = loc2 = true;
            this._desTx.wordWrap = loc2;
            this._tilePanel = new TilePanel();
            this._tilePanel.horizontalGap = 30;
            this._tilePanel.columnWidth = 90;
            this._tilePanel.rowHeight = 112;
            this._tilePanel.columnCount = 3;
            this._tilePanel.rowCount = 1;
            this._tilePanel.setSize(362, 122);
            this._tilePanel.setStyle("cellRenderer", PrizeFallRender);
            this._tilePanel.move(48, 152);
            addChild(this._tilePanel);
            LoaderHelp.addResCallBack(ResFileConst.PrizeFall, this.onLoadBmResource);
            var loc1=Language.getString(70756).split(",");
            this._tilePanel.dataProvider = new DataProvider(loc1);
            this._nowGo = ObjCreate.createGButton(Language.getString(70753), 125, 280, 70, 25, this, "ButtonRedMini");
            this._autoGo = ObjCreate.createGButton(Language.getString(70754), 243, 280, 70, 25, this, "ButtonRedMini");
            this._nowGo.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClik);
            this._autoGo.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClik);
            return;
        }

        protected onBtnClik(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=new TaskTargetInfo();
            loc1.mapId = 900502;
            var loc2=this.randomXY(this._randomArr);
            loc1.x = (this._randomArr[loc2] as Object).x;
            loc1.y = (this._randomArr[loc2] as Object).y;
            loc1.targetType = EntityType.Point;
            var loc3=arg1.target;
            switch (loc3) 
            {
                case this._nowGo:
                {
                    AIManager.onAIControl(loc1, AIType.AI_Convey);
                    break;
                }
                case this._autoGo:
                {
                    if (Cache.instance.role.entityInfo.level < 70) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(60907));
                        return;
                    }
                    AIManager.onAutoPathAIControl(loc1);
                    break;
                }
            }
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._bg.bitmapData = GlobalClass.getBitmapData(ImagesConst.prizeFallBg);
            return;
        }

        /* internal  */updateInfo(arg1: Array<any>): void
        {
            this._tilePanel.dataProvider = new DataProvider(arg1);
            return;
        }

        /* internal  */randomXY(arg1: Array<any>): number
        {
            var loc1=Math.random() * arg1.length;
            return Math.floor(loc1);
        }

        public setDesTx(arg1: string): void
        {
            this._desTx.htmlText = arg1;
            return;
        }

        public setTile(arg1: string): void
        {
            title = arg1;
            return;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_desTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_tilePanel: TilePanel;

        /* internal */ /* var */_autoGo: GButton;

        /* internal */ /* var */_nowGo: GButton;

        /* internal */ /* var */_randomArr: Array<any>;
    }
